package com.yxhl.zoume.domain.interactor.splash;

import com.yxhl.zoume.data.http.repository.splash.SplashBannerRepository;
import com.yxhl.zoume.data.http.rest.param.base.RequestParamImpl;
import com.yxhl.zoume.data.http.rest.param.splash.SplashParam;
import com.yxhl.zoume.data.http.rest.response.splash.SplashResponse;
import com.yxhl.zoume.domain.DomainConstants;
import com.yxhl.zoume.domain.interactor.base.UseCase;

import javax.inject.Inject;
import javax.inject.Named;

import rx.Observable;
import rx.Scheduler;

/**
 * 项目名称：Ferrari
 * Created by menggod on 16/10/31 .
 */

public class SplashUseCase extends UseCase<SplashResponse> {
    private SplashBannerRepository mSplashBannerRepository;

    @Inject
    public SplashUseCase(@Named(DomainConstants.UI_THREAD) Scheduler uiThread,
                         @Named(DomainConstants.EXECUTOR_THREAD) Scheduler executorThread,
                         SplashBannerRepository splashBannerRepository) {
        super(uiThread, executorThread);
        mSplashBannerRepository = splashBannerRepository;
    }

    @Override
    protected Observable<SplashResponse> buildObservable(RequestParamImpl param) {
        SplashParam splashParam = (SplashParam) param;
        return mSplashBannerRepository.obtainSplash(splashParam.getClientSystem(), splashParam.getScreen())
                .observeOn(uiThread)
                .subscribeOn(executorThread);
    }
}
